<template>
	<view class="content">
		<navbar title='报名记录'>
		</navbar>
		<u-sticky offset-top="0">
			<view class="souview">
				<view style="width: 100%;">
					<u-tabs :list="tablist" :is-scroll="false" inactive-color="#666666" active-color="#3E65E5" :current="current" @change="change"></u-tabs>
				</view>
				
			</view>
		</u-sticky>
		<view class="fone plr">

			<view class="list">
				<view class="item" v-for="(item,index) in list" :key="index" @click="getkao(item)">
					<view class="itemone">
						<text class="xname">{{ item.paper.name }}</text>
						<text class="ztai ztais">{{ item.status_name }}</text>
					</view>
					<view class="falist">
						<text class="kaoname">考试开始时间： <text class="kval">{{ item.created_at }}</text> </text>
						<text class="kaoname">报名截至时间： <text class="kval">{{item.paper.end_date}}</text> </text>
						<text class="kaoname">考试日期： <text class="kval">{{item.paper.start_date}}</text> </text>
					</view>
					<!-- <view class="kaibot" v-if="current!=2">
						<view class="cha">查看详情</view>
					</view> -->
					<view class="kaibot" v-if="item.status==1">
						<view class="kaipview" @click="getkai(item)">开始考试</view>
					</view>
				</view>
				<view class="nodata" v-if="list == ''">
					<u-empty text="暂无数据" mode="list" ></u-empty>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleStyle:{
					fontWeight: 'bold',
					fontSize: '36rpx',
					color: '#111111',
				},
				value:'',
				current:0,
				tablist: [{
					name: '全部'
				}, {
					name: '待审核'
				}, {
					name: '已通过'
				}, {
					name: '被拒绝'
				}],
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				newstatus:'',
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			async getList(){//列表数据
				let newstatus =''
				if(this.current == 0){
					newstatus = ''
				}else if(this.current == 1){
					newstatus = '0'
				}else if(this.current == 2){
					newstatus = '1'
				}else if(this.current == 3){
					newstatus = '2'
				}
				let res = await this.$u.api.toentrylist({
					limit:this.limit,
				  	page:this.page,
					type:'2',
					status:newstatus
				});
				this.last_page = res.list.last_page;
				let list = res.list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];	
				if(this.page >= this.last_page){
				  this.status = 'nomore';
				}
				
			},
			loadmore() {
				let page = this.page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			change(e){
				this.current = e
				this.getClear()
			},
			getDetail(){
				this.navrouter("/pages/StudPage/Detail");
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			},
			async getkai(item){
				let res = await this.$u.api.kaostart({
					test_entry_id:item.id
				});
				this.navrouter("/pages/StudPage/Exampaper?paper_id="+item.paper_id+'&lei=2');
				// test_entry_id
			},
			getkao(item){
				if(item.status == 10){
					//考试进行中
					this.navrouter("/pages/StudPage/Exampaper?paper_id="+item.paper_id+'&lei=2');
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		min-height: 100vh;
		background-color: #f5f5f5;
		

		.souview{
			background-color: #fff;
			padding: 20rpx 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			width: 100%;
			.shaiview{
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 15rpx;
				background: #EEEEEE;
				border-radius: 10rpx;
				.shainame{
					font-weight: 500;
					font-size: 24rpx;
					color: #51565D;
				}
				.icon_sx{
					width: 24rpx;
					height: 24rpx;
					margin-left: 10rpx;
				}
			}
			
			.souitem{
				height: 78rpx;
				background: #F5F5F5;
				border-radius: 39rpx;
				display: flex;
				align-items: center;
				flex-direction: row;
				padding: 0 23rpx;
				width: 100%;
				.icon_sousuo{
					width: 24rpx;
					height: 24rpx;
					margin-right: 15rpx;
				}
				.soubtn{
					margin-left: 20rpx;
					width: 100rpx;
					height: 50rpx;
					background: #3E65E5;
					border-radius: 25rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
				}
			}
		}
		.fone{
			margin-top: 20rpx;
			.flist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.fitem{
					width: 25%;
					display: flex;
					flex-direction:column;
					align-items: center;
					justify-content: center;
					margin-bottom: 44rpx;
					text{
						display: inline-block;
						margin-top: 13rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
					.ficon{
						width: 80rpx;
						height: 80rpx;
					}
				}
			}
			.shenhe{
				height: 60rpx;
				background: #F3F6F9;
				border-radius: 10px;
				padding: 0 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				.shenitem{
					width: 33.33%;
					display: flex;
					flex-direction: row;
					align-items: center;
					border-right: 1rpx solid rgba(62,101,229,0.3);
					justify-content: center;
					.shenone{
						margin-right: 3rpx;
						width: 33rpx;
						height: 33rpx;
					}
					.shentit{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #3C66DE;

					}
				}
				.shenitem:last-child{
					border-right: none;
				}
			}

			.leiview{
				width: 100%;
				.leiscview{
					white-space: nowrap;
					// overflow-x: auto;
					.leiitem{
						display: inline-block;
						padding: 20rpx 40rpx;
						background: #EEEEEE;
						border-radius: 16rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
						margin-right: 20rpx;
					}
					.lactive{
						background: #3E65E5;
						color: #fff;

					}
				}
				
			}
		}
		.list{
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			margin-top: 30rpx;

			.item{
				width: 100%;
				display: flex;
				flex-direction: column;
				margin-bottom: 20rpx;
				background-color: #fff;
				border-radius: 10rpx;
				padding: 0 30rpx 20rpx;
				position: relative;
				// border: 1rpx solid #eee;
				// box-shadow: 0px 3rpx 9rpx 0px rgba(109,109,109,0.1);
				.itemone{
					display: flex;
					flex-direction: row;
					align-items: center;
					padding: 20rpx 0;
					border-bottom: 1rpx solid #EEEEEE;

					.xname{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 30rpx;
						color: #51565D;
					}
					.guan{
						position: absolute;
						right: 0;
						width: 140rpx;
						height: 44rpx;
						background: #3E65E5;
						border-radius: 22rpx 0rpx 2rpx 22rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						font-weight: 500;
						font-size: 24rpx;
						color: #EAEFFF;
					}
				}
				.ztai{
					margin-left: auto;
					font-family: PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #999999;
				}
				.ztais{
					color: #3E65E5;
				}
				.falist{
					display: flex;
					flex-direction: column;
					padding: 20rpx 0 ;
					border-bottom: 1rpx solid #eee;
					.kaoname{
						display: block;
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						margin-bottom: 20rpx;
					}
					.kval{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #3E65E5;
					}
					.tubg{
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
						margin-right: 20rpx;
					}
					.faright{
						display: flex;
						flex-direction: column;
						flex: 1;
						// justify-content: center;
						padding-top: 14rpx;
						height: 100%;
						.fname{
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
							margin-bottom: 15rpx;
						}
						.fqian{
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 26rpx;
							color: #E53E3E;
							display: block;
							margin-top: auto;
							margin-bottom: 10rpx;
						}
						.qnum{
							font-size: 36rpx;
						}
					}
				}
				.kaibot{
					display: flex;
					justify-content: flex-end;
					margin-top: 30rpx;
					.cha{
						background: #EEEEEE;
						border-radius: 10rpx;
						padding: 12rpx 40rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #666;
					}
					.kaipview{
						padding: 14rpx 50rpx;
						background: #496EE7;
						border-radius: 10rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #F5F5F5;
					}
				}
				.kao{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #666666;
					display: inline-block;
					margin-right: 5rpx;
					// padding: 20rpx 0;
					margin-top: 20rpx;
				}
				.time{
					font-weight: 500;
					font-size: 28rpx;
					color: #3E65E5;
				}
				.tubg{
					width: 100%;
					height: 330rpx;
					margin-bottom: 20rpx;
				}
				.botview{
					display: flex;
					flex-direction: column;
					padding: 20rpx ;
				}
				.biaoti{
					display: inline-block;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
				}
				.pjia{
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #E53E3E;
					display: block;
					margin-top: 20rpx;
					.pnum{
						font-size: 36rpx;
					}
				}
			}
			.item:nth-child(even){
				margin-left: auto;
			}
		}
		.txt {
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.plr{
			padding: 0 30rpx;
		}
		.ftit{
			display: block;
			margin-bottom: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 36rpx;
			color: #111111;
		}



	}
</style>